package cn.sinonet.mb.processhandler;

import java.sql.Connection;
import java.util.Map;

import org.limp.basework.MachiningException;
import org.limp.basework.SimpleBean;
import org.limp.basework.SimpleBeanMachining;
import org.limp.basework.Table;
import org.limp.basework.impl.CommonBean4HSQ;

/**
 * 过程控制器注册数据操作插件
 * 
 * @author mido
 * 
 */
public class MPHMachining implements SimpleBeanMachining {
	public SimpleBean machining(SimpleBean bean, Table table,
			CommonBean4HSQ cbh, Connection conn, int type)
			throws MachiningException {
		// TODO Auto-generated method stub
		Map beanResource = bean.getResource();

		if (type == -1) {
			String className = (String) beanResource.get("PHCLASS");

			if (MPHCenter.validHandlerClass(className)) {
				beanResource.put("PHVALID", "0");
			} else {
				beanResource.put("PHVALID", "-1");
			}
		} else if (type == -2) {
			String className = (String) beanResource.get("PHCLASS");

			if (MPHCenter.validHandlerClass(className)) {
				beanResource.put("PHVALID", "0");
			} else {
				beanResource.put("PHVALID", "-1");
			}
		}

		return null;
	}
}
